<template>
  <div>
    <el-form :inline="true" :model="queryParams" class="demo-form-inline">
      <el-form-item label="省" prop="provinceSelected">
        <el-select v-model="queryParams.provinceSelected" @change="getshiid()" clearable placeholder="请选择省">
          <el-option v-for="item in shengoptions" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="市" prop="citySelected">
        <el-select v-model="queryParams.citySelected" @change="getxianid()" clearable placeholder="请选择市">
          <el-option v-for="item in shioptions" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="区" prop="countrySelected">
        <el-select v-model="queryParams.countrySelected" clearable placeholder="请选择区">
          <el-option v-for="item in xianoptions" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input v-model="queryParams.name" placeholder="请输入楼盘关键字"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table   :data="roomList">
      <el-table-column label="id" prop="id" width="120" />
      <el-table-column label="楼盘名称" prop="flatName" width="120" />
      <el-table-column label="预约人" prop="showingsName" width="120" />
      <el-table-column label="联系人电话" prop="showingsMobile" width="120" />
      <el-table-column label="预约房源" prop="roomName" width="120" />
      <el-table-column prop="reserveTime" label="预约时间" width="120">
      </el-table-column>
      <el-table-column prop="status" label="预约状态" width="120">
        <template slot-scope="scope">
          <div v-if="scope.row.status==0">
            待看房
          </div>
          <div v-else-if="scope.row.status==1">
            已看房
          </div>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    ></pagination>
  </div>
</template>

<script>
  import {listRoom} from "../../../api/hourse/room";
  import {getsheng,getshi,getxian} from "../../../api/system/info";

  export default {
    name: "index",
    data() {
      return {
        roomList: [],
        //省
        shengoptions:[],
        shioptions:[],
        xianoptions:[],
        ljform:{
          pid:0
        },
        queryParams: {
          pageNum: 1,
          pageSize: 10,

        },
        total:0,
      }
    },
    created() {
      this.getList();
      this.getsheng();

    },
    methods: {
      /** 查询租客列表 */
      getList() {
        listRoom(this.addDateRange(this.queryParams)).then(
          response => {
            this.roomList = response.rows;
            this.total = response.total;
          }
        );
      },
      getsheng(){
        getsheng().then(response => {
          console.log(response)
          this.shengoptions=response;
        });
      },
      getshiid(){
        console.log("getshi:",this.queryParams);
        getshi(this.queryParams).then(response=>{
          this.shioptions=response;
        })
      },
      getxianid(){
        console.log("getxian:",this.queryParams);
        getxian(this.queryParams).then(response=>{
          this.xianoptions=response;
        })
      },

      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
    }
  }
</script>

<style scoped>

</style>
